/*
 * @Description:
 * @Author: 郑灶欣
 * @Date: 2021-12-16 14:56:06
 * @LastEditors: 郑灶欣
 * @LastEditTime: 2021-12-20 15:45:09
 * @FilePath: \vue3-admin\vite.config.js
 */
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";

const baseUrl = {
  development: "./",
  beta: "./",
  release: "./",
};

// https://vitejs.dev/config/
export default ({ mode }) =>
  defineConfig({
    plugins: [vue()],
    base: baseUrl[mode],
    //引入全局样式
    css: {
      preprocessorOptions: {
        scss: {
          loader: 'sass-resources-loader',
          additionalData: `@import "/src/style/index.scss";`,
        },
      },
    },
    resolve: {
      alias: {
        "~": path.resolve(__dirname, "./"),
        "@": path.resolve(__dirname, "src"),
      },
    },
    server: {
      proxy: {
        "/api": {
          target: "http://backend-api-02.newbee.ltd/manage-api/v1",
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ""),
        },
      },
    },
  });
